package com.recommended.config;

import org.apache.mahout.cf.taste.impl.model.file.FileDataModel;
import org.apache.mahout.cf.taste.model.DataModel;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.File;
import java.io.IOException;
import java.net.URL;

/**
 * mahout推荐算法配置
 *
 * @author Administrator
 */
@Configuration
public class MahoutConfig {
    @Bean(value = "fileDataModel")
    public DataModel getDataModel() throws IOException {
        URL url = MahoutConfig.class.getClassLoader().getResource("mahout/ratings1.data");
        DataModel dataModel = new FileDataModel(new File(url.getFile()));
        return dataModel;
    }
}
